﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;

namespace Árvore_Binária_de_Pesquisa
{
    public enum TraversalClicked
    {
        preOrderRight,
        inOrderRight,
        postOrderRight,
        preOrderLeft,
        inOrderLeft,
        postOrderLeft        
    }

    public struct TraversalPositions
    {
        public Array positions;
        public Array addNodeVisited;
    }

    public class Traversals
    {
        public Traversals()
        {

        }
        private static TraversalPositions cp = new TraversalPositions();

        /// <summary>
        /// Acolording to the traversal selected, it returns the positions that will be visited 
        /// during the animations and the information if the node was really visited or if it was only 
        /// a node that the animation would go over
        /// </summary>
        /// <returns></returns>
        public static TraversalPositions preOrderRight_Click()
        {
            /*Pre-Order Right (root - right - esq) * a-c-g-f-b-e-d // a c g o n f m l b e k j d i h*/
            
            cp.positions = new int[] { 0, 2, 6, 14, 13, 5, 12, 11, 1, 4, 10, 9, 3, 8, 7 };

            cp.addNodeVisited = new bool[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true };

            return cp;
            
        }

        public static TraversalPositions inOrderRight_Click()
        {
            /*In-Order Right (right -root - esq) * g-c-f-a-e-b-d // o g n c m f l a k e j b i d h*/

            cp.positions = new int[] { 0, 2, 6, 14, 6, 13, 2, 5, 12, 5, 11, 0, 1, 4, 10, 4, 9, 1, 3, 8, 3, 7 };
            
            cp.addNodeVisited = new bool[]{false, false, false, true, true, true, true, false, true, true, true, true, false, false, true, true, true, true, false, true, true, true};
            
            return cp;
        }

        public static TraversalPositions postOrderRight_Click()
        {
            /*Post-Order Right (right - left - root) * g-f-c-e-d-b-a // o n g m l f c k j e i h d b a*/

            cp.positions = new int[] { 0, 2, 6, 14, 13, 6, 5, 12, 11, 5, 2, 1, 4, 10, 9, 4, 3, 8, 7, 3, 1, 0 };
            
            cp.addNodeVisited = new bool[] { false, false, false, true, true, true, false, true, true, true, true, false, false, true, true, true, false, true, true, true, true,true};

            return cp;
        }

        public static TraversalPositions preOrderLeft_Click()
        {
            /*Pre-Order Left (root - left - right) * a-b-d-e-c-f-g // a b d h i e j k c f l m g n o*/

            cp.positions = new int[] { 0, 1, 3, 7, 8, 4, 9, 10, 2, 5, 11, 12, 6, 13, 14 };
            
            cp.addNodeVisited = new bool[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};

            return cp;
        }

        public static TraversalPositions inOrderLeft_Click()
        {
            /*In-Order Left (left -root - right) * d-b-e-a-f-c-g  // h d i b j e k a l f m c n g o*/

            cp.positions = new int[] { 0, 1, 3, 7, 3, 8, 1, 4, 9, 4, 10, 0, 2, 5, 11, 5, 12, 2, 6, 13, 6, 14 };
            
            cp.addNodeVisited = new bool[]{false, false, false, true, true, true, true, false, true, true, true, true, false, false, true, true, true, true, false, true, true, true};

            return cp;
        }

        public static TraversalPositions postOrderLeft_Click()
        {
            /*Post-Order Left (left - right - root) * d-e-b-f-g-c-a // h i d j k e b l m f n o g c a*/

            cp.positions = new int[] { 0, 1, 3, 7, 8, 3, 4, 9, 10, 4, 1, 2, 5, 11, 12, 5, 6, 13, 14, 6, 2, 0 };
            
            cp.addNodeVisited = new bool[] { false, false, false, true, true, true, false, true, true, true, true, false, false, true, true, true, false, true, true, true, true,true};

            return cp;
        }

    }
}
